Fixes numerical issues with N0f8 types#65
Conversation
There was a problem hiding this comment.
Pull request overview
Adds regression coverage around Contrast Limited Adaptive Histogram Equalization (CLAHE) to prevent conversion errors on fixed-point grayscale images and to ensure raw numeric arrays are supported (per issue #64).
Changes:
- Add a CLAHE regression test for
Gray{N0f8}inputs (issue #64). - Add a CLAHE test ensuring
UInt8matrices are handled without conversion failures and preserveUInt8output.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # https://github.com/JuliaImages/ImageContrastAdjustment.jl/issues/64 | ||
| rng = StableRNG(123) | ||
| # A sufficiently large random image would previously trigger the same issue as reported above | ||
| img = Gray{N0f8}.([only(rand(rng,1)) for r = 1:600, c = 1:600]) |
There was a problem hiding this comment.
Done in latest push
| @test minimum(imgeq) >= Gray{N0f8}(0) | ||
| @test maximum(imgeq) <= Gray{N0f8}(1) |
There was a problem hiding this comment.
I do this instead now:
minval = 0
maxval = 1
algo = AdaptiveEqualization( nbins = 256, minval = minval, maxval = maxval, rblocks = 4, cblocks = 4, clip = 0.2)
imgeq = adjust_histogram(img, algo)
@test minimum(imgeq) >= Gray{N0f8}(minval)
@test maximum(imgeq) <= Gray{N0f8}(maxval)
Another issue that arose is that we try to simultaneously support canonical JuliaImages image types, as well as the ability to pass in a matrix of raw numbers. Using the function `gray` on a raw number throws an error. I've refactored some key lines so that gray is only utilised on JuliaImages types.
|
It's been too long since I last committed to the ecosystem, so I am out of the loop regarding the CI. Need to investigate how to get them working again.
|
|
@timholy @johnnychen94 Its been a while since I had the capacity to contribute to the ecosystem, so I'm a bit out of touch with the current protocol for reviewing, merging, tagging and releasing. |
There was a problem hiding this comment.
Looks great to me! Very clean changes. (except that I would use <name>/<feat_name> rather than n0f8 as the branch name :P )
To make a release, just make a comment at the release commit with @JuliaRegistrator register should be okay, I believe (https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app)
Fixes #64
Another issue that arose is that we try to simultaneously support canonical JuliaImages image types, as well as the ability to pass in a matrix of raw numbers. Using the function
grayon a raw number throws an error. I've refactored some key lines so that gray is only utilised on JuliaImages types.